package com.lh.utils;

public class ResultOne<T> {
    private boolean success = false;
    private String msg = new String();
    private T data;
    private String id;

    public static <T> ResultOne<T> build() {
        return new ResultOne<T>();
    }

    public static <T> ResultOne<T> success(T data, String msg) {
        return new ResultOne<T>().setSuccess(true).setData(data).setMsg(msg);
    }

    public static <T> ResultOne<T> success(T data) {
        return new ResultOne<T>().setSuccess(true).setData(data);
    }

    public static <T> ResultOne<T> fail(String msg) {
        return new ResultOne<T>().setSuccess(false).setMsg(msg);
    }

    public static <T> ResultOne<T> fail(T data, String msg) {
        return new ResultOne<T>().setSuccess(false).setData(data).setMsg(msg);
    }

    public boolean isSuccess() {
        return success;
    }

    public ResultOne<T> setSuccess(boolean success) {
        this.success = success;
        return this;
    }

    public String getMsg() {
        return msg;
    }

    public ResultOne<T> setMsg(String msg) {
        this.msg = msg;
        return this;
    }

    public T getData() {
        return data;
    }

    public ResultOne<T> setData(T data) {
        this.data = data;
        return this;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }
}